package edu.pku.sei.act.main.provider;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;

import edu.pku.sei.act.images.ArchiModelImageProvider;
import edu.pku.sei.act.model.common.ArchiModel;
import edu.pku.sei.act.model.mote.AcceptAction;
import edu.pku.sei.act.model.mote.Action;
import edu.pku.sei.act.model.mote.ActivityFinal;
import edu.pku.sei.act.model.mote.Data;
import edu.pku.sei.act.model.mote.DecisionNode;
import edu.pku.sei.act.model.mote.InitialNode;
import edu.pku.sei.act.model.mote.LIP;
import edu.pku.sei.act.model.mote.MergeNode;
import edu.pku.sei.act.model.mote.Mote;
import edu.pku.sei.act.model.mote.MoteForPackage;
import edu.pku.sei.act.model.mote.PackageI;
import edu.pku.sei.act.model.mote.Radio;
import edu.pku.sei.act.model.mote.SendAction;
import edu.pku.sei.act.model.mote.SimpleDevice;
import edu.pku.sei.act.model.mote.Task;
import edu.pku.sei.act.model.mote.TaskEditArea;
import edu.pku.sei.act.model.mote.Timer;
import edu.pku.sei.gmp.model.shape.GMPDiagram;
import edu.pku.sei.gmp.resource.image.GMPImageProvider;

public class ArchiModelerLabelProvider implements ILabelProvider{

	@Override
	public Image getImage(Object element) {
		ImageDescriptor iDesc;
		if(element instanceof ArchiModel){
			iDesc = GMPImageProvider.getImageDescriptor(GMPImageProvider.MODEL_VIEW);
		} else if (element instanceof Mote) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.MOTE);
		}else if (element instanceof GMPDiagram) {
			iDesc = GMPImageProvider
			.getImageDescriptor(GMPImageProvider.DIAGRAM);
		}else if(element instanceof Data){
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.DATA);
		}else if(element instanceof Radio){
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.RADIO);
		}else if(element instanceof Timer){
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.TIMER);
		}else if(element instanceof SimpleDevice){
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.SIMPLEDEVICE);
		}else if(element instanceof LIP){
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.LIP);
		}else if (element instanceof PackageI) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.PACKAGE);
		}else if (element instanceof Task) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.TASK);
		}else if (element instanceof MoteForPackage) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.MOTE);
		}else if (element instanceof InitialNode) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.INITIALNODE);
		}else if (element instanceof Action) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.ACTION);
		}else if (element instanceof SendAction) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.SENDACTION);
		}else if (element instanceof AcceptAction) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.ACCEPTACTION);
		}else if (element instanceof DecisionNode) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.DECISIONNODE);
		}else if (element instanceof MergeNode) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.MERGENODE);
		}else if (element instanceof ActivityFinal) {
			iDesc = ArchiModelImageProvider.getImageDescriptor(ArchiModelImageProvider.ACTIVITYFINAL);
		}else {
			iDesc = GMPImageProvider
			.getImageDescriptor(GMPImageProvider.UNKNOWN);
		}
		return iDesc.createImage();
	}

	@Override
	public String getText(Object element) {
		if(element instanceof ArchiModel){
			return new String("Architecture Model");
		}else if(element instanceof Mote){
			return ((Mote)element).getName();
		}else if (element instanceof GMPDiagram) {
			return new String(((GMPDiagram) element).getName());
		}else if (element instanceof Data){
			return "Data";
		}else if (element instanceof Timer){
			return "Timer";
		}else if (element instanceof SimpleDevice){
			return "SimpleDevice";
		}else if (element instanceof LIP){
			return "LIP";
		}else if (element instanceof Radio){
			return "Radio";
		}else if (element instanceof Task){
			return "Task";
		}else if(element instanceof TaskEditArea){
			return "Task";
		}else if(element instanceof InitialNode){
			return "InitialNode";
		}else if(element instanceof Action){
			return "Action";
		}else if(element instanceof SendAction){
			return "SendAction";
		}else if(element instanceof AcceptAction){
			return "AcceptAction";
		}else if(element instanceof DecisionNode){
			return "DecisionNode";
		}else if(element instanceof MergeNode){
			return "MergeNode";
		}else if(element instanceof ActivityFinal){
			return "ActivityFinal";
		}else if (element instanceof PackageI){
			return ((PackageI)element).getName();
		}else if (element instanceof MoteForPackage){
			return((MoteForPackage)element).getName();
		}
		return null;
	}

	@Override
	public void addListener(ILabelProviderListener listener) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean isLabelProperty(Object element, String property) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void removeListener(ILabelProviderListener listener) {
		// TODO Auto-generated method stub
		
	}

}
